package com.tianda.rbac_demo.exception;

import cn.dev33.satoken.exception.NotPermissionException;
import com.tianda.rbac_demo.domain.BaseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CustomExceptionHandler {

    @ExceptionHandler(BusException.class)
    public BaseResult handleException(BusException e) {
        return BaseResult.error(e.getCode(),e.getMessage());
    }

    /**
     * 捕获并处理没有权限异常
     */
    @ExceptionHandler(NotPermissionException.class)
    public BaseResult handleException(NotPermissionException e) {
        return BaseResult.error(10010,e.getMessage());
    }

}
